﻿@using Newtouch.Infrastructure;

@{
    Layout = "~/Views/Shared/_Form.cshtml";

    var isPrintRehabPres = (ViewBag.ISPrintRehabPres as bool?) ?? false;
    var isPrintRehabTreatment = (ViewBag.ISPrintRehabTreatment as bool?) ?? false;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>HistoryMedicalRecordForm</title>
</head>
<body>
    @Html.Partial("_YibaoCommonView")
    <div>
        <div id="dispDiv" class="panel panel-default" style="height: auto; margin-top:50px;padding: 0 20px 0 0;
    border: 0;">
            <div class="panel-heading">
                历史病历&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i id="hideDispDiv" class="fa fa-eye-slash" style="font-size:larger;"></i>
            </div>
            <div class="historyleft" style="height: 480px; float: left; width: 20%; height: 60%;">
                <div class="bltree">
                    <div class="widget-body">
                        <div id="detailTreeNode" style="border-right:solid 1px #ddd;border-bottom:solid 1px #ddd;"></div>
                    </div>
                </div>
                @*<button id="btncopy" class="btn btn-primary" style="margin: 10% 0 0 32%;">复制</button>*@
            </div>
            <div class="historydetail" id="TreeNodeContent" style="margin-left: 20.5%; width: 79.5%;">
                <table class="form supercompact">
                    <tr>
                        <th class="formTitle">主诉：</th>
                        <td class="formValue" colspan="2">
                            <input type="text" id="nc_zs" name="nc_zs" class="form-control" />
                        </td>
                        <th class="formTitle">发病日期：</th>
                        <td class="formValue">
                            <input type="text" id="nc_fbsj" class="form-control input-wdatepicker" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">现病史：</th>
                        <td class="formValue" colspan="4">
                            <textarea id="nc_xbs" name="nc_xbs" class="form-control " style="height:35px;"></textarea>
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">既往史：</th>
                        <td class="formValue" colspan="4">
                            <textarea id="nc_jws" name="nc_jws" class="form-control " style="height:35px;"></textarea>
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">月经史：</th>
                        <td class="formValue" colspan="4">
                            <textarea id="nc_yjs" name="nc_yjs" class="form-control " style="height:35px;"></textarea>
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">过敏史：</th>
                        <td class="formValue" colspan="4">
                            <textarea id="nc_gms" name="nc_gms" class="form-control " style="height:35px;"></textarea>
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">查体：</th>
                        <td class="formValue" colspan="4">
                            <textarea id="nc_ct" name="nc_ct" class="form-control " style="height:35px;"></textarea>
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">处理：</th>
                        <td class="formValue" colspan="4">
                            <textarea id="nc_clfa" name="nc_clfa" class="form-control activeValue focusInput" style="height:35px;"></textarea>
                            <i class="fa fa-times" aria-hidden="true" hidden></i>
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">辅助检查：</th>
                        <td class="formValue" colspan="4">
                            <textarea id="nc_fzjc" name="nc_fzjc" class="form-control activeValue focusInput" style="height:35px;"></textarea>
                            <i class="fa fa-times" aria-hidden="true" hidden></i>
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">婚姻状态：</th>
                        <td class="formValue">
                            <select id="nc_hy">
                                <option value="">=请选择=</option>
                                <option value="1">未婚</option>
                                <option value="2">已婚</option>
                                <option value="3">不详</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">西医诊断：</th>
                        <td class="formValue" colspan="4">
                            <table id="nc_tablexyzd">
                                <tr>
                                    <th class="formTitle">主</th>
                                    <td class="formValue">
                                        <input type="checkbox" id="chk1" class="chkValue" style="float:left;" /><label style="float:left;margin-top:3px;">疑似</label>
                                        <input type="text" id="zd1" name="zd1" class="form-control activeValue focusInput nc_zdText" style="width:70%;" placeholder="" />
                                        <input type="text" id="ywxs1" name="ywxs1" class="form-control activeValue focusInput nc_ywxsText" style="width:70%;" placeholder="" />
                                        <i class="fa fa-times" aria-hidden="true" hidden></i>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">中医诊断：</th>
                        <td class="formValue" colspan="4">
                            <table id="nc_tablezyzd">
                                <tr>
                                    <th class="formTitle">主</th>
                                    <td class="formValue">
                                        <input type="checkbox" id="chk1" class="chkValue" style="float:left;" /><label style="float:left;margin-top:3px;">疑似</label>
                                        <input type="text" id="zd1" name="zd1" class="form-control activeValue focusInput nc_zdText" style="width:70%;" />
                                        <i class="fa fa-times" aria-hidden="true" hidden></i>
                                    </td>
                                    <th class="formTitle">症候</th>
                                    <td class="formValue">
                                        <input type="text" id="zh1" class="form-control activeValue focusInput nc_zhText" />
                                        <i class="fa fa-times" aria-hidden="true" hidden></i>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    @*@if (isOpenKfcf == true)
                        {*@
                    <tr>
                        <th class="formTitle">康复：</th>
                        <td class="formValue" colspan="4">
                            <div style="border: 1px solid #ddd; border-radius:4px;height:auto;">
                                <table style="width: 100%; margin: 5px 0px 5px 3px;">
                                    <tr>
                                        <th style="width: 150px;">处方号</th>
                                        <th></th>
                                    </tr>
                                    <tbody id="tableNC_KfMx"></tbody>
                                </table>
                            </div>
                        </td>
                    </tr>
                    @*}
                        @if (isOpenCgxmcf == true)
                        {*@
                    <tr>
                        <th class="formTitle">常规项目：</th>
                        <td class="formValue" colspan="4">
                            <div style="border: 1px solid #ddd; border-radius:4px;height:auto;">
                                <table style="width: 100%; margin: 5px 0px 5px 3px;">
                                    <tr>
                                        <th style="width: 150px;">处方号</th>
                                        <th></th>
                                    </tr>
                                    <tbody id="tableNC_CgxmMx"></tbody>
                                </table>
                            </div>
                        </td>
                    </tr>
                    @*}*@
                    <tr>
                        <th class="formTitle">西药：</th>
                        <td class="formValue" colspan="4">
                            <div style="border: 1px solid #ddd; border-radius:4px; height:auto;">
                                <table style="width: 100%; margin: 5px 0px 5px 3px;">
                                    <tr>
                                        <th style="width: 150px;">处方号</th>
                                        <th></th>
                                    </tr>
                                    <tbody id="tableNC_XyMx"></tbody>
                                </table>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">中药：</th>
                        <td class="formValue" colspan="4">
                            <div style="border: 1px solid #ddd; border-radius:4px; height:auto;">
                                <table style="width: 100%; margin: 5px 0px 5px 3px;">
                                    <tr>
                                        <th style="width: 150px;">处方号</th>
                                        <th></th>
                                    </tr>
                                    <tbody id="tableNC_ZyMx"></tbody>
                                </table>
                            </div>
                        </td>
                    </tr>
                    @*@if (IsOpenJyJcSwitch == true)
                        {*@
                    <tr>
                        <th class="formTitle">检验：</th>
                        <td class="formValue" colspan="4">
                            <div style="border: 1px solid #ddd; border-radius:4px;height:auto;">
                                <table style="width: 100%; margin: 5px 0px 5px 3px;">
                                    <tr>
                                        <th style="width: 150px;">申请单号</th>
                                        <th></th>
                                    </tr>
                                    <tbody id="tableNC_JyMx"></tbody>
                                </table>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">检查：</th>
                        <td class="formValue" colspan="4">
                            <div style="border: 1px solid #ddd; border-radius:4px; height:auto;">
                                <table style="width: 100%; margin: 5px 0px 5px 3px;">
                                    <tr>
                                        <th style="width: 150px;">申请单号</th>
                                        <th></th>
                                    </tr>
                                    <tbody id="tableNC_JcMx"></tbody>
                                </table>
                            </div>
                        </td>
                    </tr>
                    @*}*@
                </table>
            </div>
            <table id="lsblfrombilling">
                <tr>
                    <th hidden>类型</th>
                    <th style="width:20%">文件</th>
                    <th style="width:35%">路径</th>
                    <th style="width:35%">备注</th>
                    <th style="width:10%">查看</th>
                </tr>
            </table>
        </div>

    </div>
</body>
</html>


<script>

    //var test = $.request("test");
    //var ajaxresp = $.request("ajaxresp");
    var ex2 = $.request("ex2");
    var jzid = $.request("jzid");
    //var Id = $.request("Id");
    //var pageType = $.request("pageType");
    //var jzzt = $.request("jzzt");
    var ajaxresp = {};


    init();

    function init() {

        var obj = {
            kfcf: new Array(),
            cgxmcf: new Array(),
            xycf: new Array(),
            zycf: new Array(),
            jycf: new Array(),
            jccf: new Array(),
        }
        window.historydataArray = obj;

        //if (pageType != "yczl") {
            getHistoryData();
        //}
    }

    function getHistoryData() {
         $.najax({
                            type: "POST",
             //               url: "/MedicalRecord/SelectNodeContentV2",
             //data: { jzId: jzid, Id: Id, pageType: pageType, jzzt:jzzt},
             url: "/MedicalRecord/SelectNodeContent",
             data: { jzId: jzid},
                            loadingtext :'病历数据加载中，请稍后…',
                            success: function (ajaxresp) {
                                ajaxresp = ajaxresp;

                                bindHistoryData(ajaxresp);
                            }
                        });
    }

    function bindHistoryData(ajaxresp) {
        //2.先呈现历史树结构
        $("#detailTreeNode").treeview({
            height: 400,
            slimscroll: false,
            showcheck: true,
            url: "/MedicalRecord/GetDetailTreeNode",
            oncheckboxclick: function (item) {
                if (item.hasChildren === true) {
                    return;
                }
            }
        });
           //3.填充文本
            $('#nc_zs').val(ajaxresp.zs);
            $("#nc_fbsj").val($.getDate({ date: ajaxresp.fbsj,ute:true }));
            $('#nc_xbs').val(ajaxresp.xbs);
            $('#nc_jws').val(ajaxresp.jws);
            $('#nc_yjs').val(ajaxresp.yjs);
            $('#nc_gms').val(ajaxresp.gms);
            $('#nc_hy').val(ajaxresp.hy);
            $('#nc_ct').val(ajaxresp.ct);
            $('#nc_clfa').val(ajaxresp.clfa);
            $('#nc_fzjc').val(ajaxresp.fzjc);
            $("input[name='cfzbzRadios'][value='" + ajaxresp.cfzbz + "']").attr("checked", true);
            //4.填充诊断
            if (ajaxresp.xyzdList) {
                for (var i = 0; i < ajaxresp.xyzdList.length; i++) {
                    if(ajaxresp.xyzdList.length>1 &&  i< ajaxresp.xyzdList.length-1)
                    {
                        //先append
                        var number = $('#nc_tablexyzd .nc_zdText').length + 1;
                        var $newTr = $('<tr><th class="formTitle">副</th><td class="formValue"><input type="checkbox" id="chk'+ number +'" class="chkValue" style="float:left;" /><label style="float:left;margin-top:3px;">疑似</label><input type="text" id="zd'+ number +'" class="form-control activeValue focusInput nc_zdText" style="width:70%;" /><i class="fa fa-times" aria-hidden="true" hidden></i></td></tr>');
                        $newTr.appendTo($('#nc_tablexyzd'));
                    }

                    //再赋值
                    for (var j = 0; j < $('#nc_tablexyzd .nc_zdText').length; j++) {
                        if(i==j){
                            $($('#nc_tablexyzd .nc_zdText')[j]).val(ajaxresp.xyzdList[i].zdmc);
                            $($('#nc_tablexyzd .nc_zdText')[j]).attr("data-zdCode",ajaxresp.xyzdList[i].zdCode);
                            $($('#nc_tablexyzd .nc_zdText')[i]).attr("data-icd10",ajaxresp.xyzdList[i].icd10);
                            $($('#nc_tablexyzd .chkValue')[j]).prop('checked', ajaxresp.xyzdList[i].ysbz);

                            $($('#nc_tablexyzd .nc_ywxsText')[j]).val(ajaxresp.xyzdList[i].ywxs);
                            $($('#nc_tablexyzd .nc_ywxsText')[j]).attr("data-ywlx", ajaxresp.xyzdList[i].ywlx);
                            $($('#nc_tablexyzd .nc_ywxsText')[j]).attr("data-ywstr", ajaxresp.xyzdList[i].ywstr);
                        }
                    }
                }
            }
            if (ajaxresp.zyzdList) {
                for (var i = 0; i < ajaxresp.zyzdList.length; i++) {
                    if(ajaxresp.zyzdList.length>1 &&  i< ajaxresp.zyzdList.length-1)
                    {
                        //先append
                        var number = $('#nc_tablezyzd .nc_zdText').length + 1;
                        var $newTr = $('<tr><th class="formTitle">副</th><td class="formValue"><input type="checkbox" id="chk'+ number +'" class="chkValue" style="float:left;" /><label style="float:left;margin-top:3px;">疑似</label><input type="text" id="zd'+ number +'" class="form-control activeValue focusInput nc_zdText" style="width:70%;" /><i class="fa fa-times" aria-hidden="true" hidden></i></td><th class="formTitle">症候</th><td class="formValue"><input type="text" class="form-control activeValue focusInput nc_zhText" /><i class="fa fa-times" aria-hidden="true" hidden></i></td></tr>');
                        $newTr.appendTo($('#nc_tablezyzd'));
                    }
                    //再赋值
                    for (var j = 0; j < $('#nc_tablezyzd .nc_zdText').length; j++) {
                        if(i==j){
                            $($('#nc_tablezyzd .nc_zdText')[j]).val(ajaxresp.zyzdList[i].zdmc);
                            $($('#nc_tablezyzd .nc_zdText')[j]).attr("data-zdCode",ajaxresp.zyzdList[i].zdCode);
                            $($('#nc_tablezyzd .nc_zdText')[i]).attr("data-icd10",ajaxresp.zyzdList[i].icd10);
                            $($('#nc_tablezyzd .chkValue')[j]).prop('checked' ,ajaxresp.zyzdList[i].ysbz);
                            $($('#nc_tablezyzd .nc_zhText')[j]).val(ajaxresp.zyzdList[i].zhmc);
                            $($('#nc_tablezyzd .nc_zhText')[j]).attr("data-zhCode",ajaxresp.zyzdList[i].zhCode);
                        }
                    }
                }
            }
            //5.填充处方
        if (ex2 == 'medicalRecord') {
            //清空
            window.historydataArray.kfcf = new Array();
            window.historydataArray.cgxmcf = new Array();
            window.historydataArray.xycf = new Array();
            window.historydataArray.zycf = new Array();
            window.historydataArray.jycf = new Array();
            window.historydataArray.jccf = new Array();
            $.each(ajaxresp.cfBoList, function () {
                if (this.presDetailList) {
                    //这是一个处方
                    var cflx = this.presEntity.cflx == @Html.Raw(((int)EnumCflx.RehabPres).ToString()) ? "kfcf" : this.presEntity.cflx == @Html.Raw(((int)EnumCflx.RegularItemPres).ToString()) ? "cgxmcf" : this.presEntity.cflx == @Html.Raw(((int)EnumCflx.WMPres).ToString()) ? "xycf" : this.presEntity.cflx == @Html.Raw(((int)EnumCflx.TCMPres).ToString()) ? "zycf" : this.presEntity.cflx == @Html.Raw(((int)EnumCflx.InspectionPres).ToString()) ? "jycf" : this.presEntity.cflx == @Html.Raw(((int)EnumCflx.ExaminationPres).ToString()) ? "jccf" : "0";
                    var newCfh = GetNewPresNo();    //这里有新处方号，后面就可以直接用了
                    //var newCfh = this.cfh;
                    //cfmxList
                    if (cflx == "kfcf") {
                        $.each(this.presDetailList.sort(function (a, b) { return a.px - b.px; }), function () {
                            var cfmx = {
                                sfbz: false,
                                cfId: "",
                                cfh: newCfh,
                                xmmc: this.xmmc,
                                xmCode: this.xmCode,
                                dj: this.dj,
                                dw: this.dw,
                                bw: this.bw,
                                dwjls: this.dwjls,
                                jjcl: this.jjcl,
                                mczll: this.mczll,
                                pcmc: this.pcmc,
                                pcCode: this.pcCode,
                                sl: this.sl,
                                zl: this.zl,
                                je: this.je,
                                zxks: this.zxks,
                                zxksmc: this.zxksmc,
                                ybwym: this.ybwym,
                                xzsybz: this.xzsybz,
                                cfmxId: this.cfmxId,
                                ts: this.ts
                            };
                            if (!(window.historydataArray && window.historydataArray.kfcf)) {
                                window.historydataArray.kfcf = new Array();
                            }
                            window.historydataArray.kfcf.push(cfmx);
                        });
                    }
                    //
                    if (cflx == "cgxmcf") {
                        $.each(this.presDetailList.sort(function (a, b) { return a.px - b.px; }), function () {
                            var cfmx = {
                                sfbz: false,
                                cfId: "",
                                cfh: newCfh,
                                xmmc: this.xmmc,
                                xmCode: this.xmCode,
                                dj: this.dj,
                                dw: this.dw,
                                bw: this.bw,
                                dwjls: this.dwjls,
                                jjcl: this.jjcl,
                                mczll: this.mczll,
                                pcmc: this.pcmc,
                                pcCode: this.pcCode,
                                sl: this.sl,
                                zl: this.zl,
                                je: this.je,
                                zxks: this.zxks,
                                zxksmc: this.zxksmc,
                                ybwym: this.ybwym,
                                xzsybz: this.xzsybz,
                                cfmxId: this.cfmxId,
                                ts: this.ts
                            };
                            if (!(window.historydataArray && window.historydataArray.cgxmcf)) {
                                window.historydataArray.cgxmcf = new Array();
                            }
                            window.historydataArray.cgxmcf.push(cfmx);
                        });
                    }
                    //cfmxList
                    if (cflx == "xycf") {
                        $.each(this.presDetailList.sort(function (a, b) { return a.px - b.px; }), function () {
                            var cfmx = {
                                sfbz: false,
                                cfId: "",
                                cfh: newCfh,
                                zh: this.zh,
                                ypmc: this.ypmc,
                                ypCode: this.ypCode,
                                ypgg: this.ypgg,
                                dj: this.dj,
                                mcjl: this.mcjl,
                                mcjldw: this.mcjldw,
                                mcjldwwwwwww: this.mcjldwwwwwww,
                                redundant_jldw: this.mcjldw,
                                yfmc: this.yfmc,
                                yfCode: this.yfCode,
                                pcmc: this.pcmc,
                                pcCode: this.pcCode,
                                sl: this.sl,
                                dw: this.dw,
                                je: this.je,
                                zxks: this.zxks,
                                ybwym: this.ybwym,
                                xzsybz: this.xzsybz,
                                cfmxId: this.cfmxId,
                                ts: this.ts
                            };
                            if (!(window.historydataArray && window.historydataArray.xycf)) {
                                window.historydataArray.xycf = new Array();
                            }
                            window.historydataArray.xycf.push(cfmx);
                        });
                    }
                    //cfmxList
                    if (cflx == "zycf") {
                        var tieshu = this.presEntity.tieshu;
                        var cfyf = this.presEntity.cfyf;
                        var djbz = this.presEntity.djbz;
                        $.each(this.presDetailList.sort(function (a, b) { return a.px - b.px; }), function () {
                            var cfmx = {
                                sfbz: false,
                                cfId: "",
                                cfh: newCfh,
                                //
                                ypmc: this.ypmc,
                                ypCode: this.ypCode,
                                ypgg: this.ypgg,
                                dj: this.dj,
                                mcjl: this.mcjl,
                                mcjldw: this.mcjldw,
                                sl: this.sl,
                                dw: this.dw,
                                je: this.je,
                                Remark: this.Remark,
                                zxks: this.zxks,
                                //
                                tieshu: tieshu,
                                cfyf: cfyf,
                                djbz: djbz,
                                ybwym: this.ybwym,
                                xzsybz: this.xzsybz,
                                cfmxId: this.cfmxId,
                                ts: this.ts
                            };
                            if (!(window.historydataArray && window.historydataArray.zycf)) {
                                window.historydataArray.zycf = new Array();
                            }
                            window.historydataArray.zycf.push(cfmx);
                        });
                    }
                    //cfmxList
                    if (cflx == "jycf") {
                        $.each(this.presDetailList.sort(function (a, b) { return a.px - b.px; }), function () {
                            var cfmx = {
                                sfbz: false,
                                cfId: "",
                                cfh: newCfh,
                                xmmc: this.xmmc,
                                xmCode: this.xmCode,
                                dw: this.dw,
                                dj: this.dj,
                                zxks: this.zxks,
                                zxksmc: this.zxksmc,
                                ybwym: this.ybwym,
                                xzsybz: this.xzsybz,
                                cfmxId: this.cfmxId,
                                ts: this.ts,
                                ztId: this.ztId,
                                ztmc: this.ztmc,
                                sl: this.sl,
                            };
                            if (!(window.historydataArray && window.historydataArray.jycf)) {
                                window.historydataArray.jycf = new Array();
                            }
                            window.historydataArray.jycf.push(cfmx);
                        });
                    }
                    //cfmxList
                    if (cflx == "jccf") {
                        $.each(this.presDetailList.sort(function (a, b) { return a.px - b.px; }), function () {
                            var cfmx = {
                                sfbz: false,
                                cfId: "",
                                cfh: newCfh,
                                xmmc: this.xmmc,
                                xmCode: this.xmCode,
                                dw: this.dw,
                                dj: this.dj,
                                zxks: this.zxks,
                                zxksmc: this.zxksmc,
                                ybwym: this.ybwym,
                                xzsybz: this.xzsybz,
                                cfmxId: this.cfmxId,
                                ts: this.ts,
                                sl: this.sl,
                                bw: this.bw,
                                ztId: this.ztId,
                                ztmc: this.ztmc
                            };
                            if (!(window.historydataArray && window.historydataArray.jccf)) {
                                window.historydataArray.jccf = new Array();
                            }
                            window.historydataArray.jccf.push(cfmx);
                        });
                    }
                }
            });
            triggleActive("historynodeContent");
        }
    }

    //获取新处方号
    function GetNewPresNo() {
        var newPresNo;
        $.najax({
            url: "/Prescription/GetNewPresNo",
            dataType: "text",
            async: false,
            success: function (data) {
                newPresNo = data;
            }
        });
        return newPresNo;
    }

    function triggleActive(typeFlag) {
        var newdataArray = new Array();
        var $newtableKfmx;
        var $newtableCgxmmx;
        var $newtableXymx;
        var $newtableZymx;
        var $newtableJymx;
        var $newtableJcmx;
        if(typeFlag == "historynodeContent"){   //结束就诊的病历内容
            newdataArray = window.historydataArray;
            $newtableKfmx = $('#tableNC_KfMx');
            $newtableCgxmmx = $('#tableNC_CgxmMx');
            $newtableXymx = $('#tableNC_XyMx');
            $newtableZymx = $('#tableNC_ZyMx');
            $newtableJymx = $('#tableNC_JyMx');
            $newtableJcmx = $('#tableNC_JcMx');
        }
        else{
            newdataArray = window.alldataArray;
            $newtableKfmx = $('#tableKfMx');
            $newtableCgxmmx = $('#tableCgxmMx');
            $newtableXymx = $('#tableXyMx');
            $newtableZymx = $('#tableZyMx');
            $newtableJymx = $('#tableJyMx');
            $newtableJcmx = $('#tableJcMx');
        }
        if (newdataArray && Object.keys(newdataArray)) {
            //alldataArray :[kfcf:[{cfh：‘处方1’，xmmc：‘’},{cfh：‘处方2’，xmmc：‘’}，{cfh：‘处方1’，xmmc：‘’}]]
            //1.遍历所有数据
            $.each(Object.keys(newdataArray), function () {    //Object.keys(newdataArray):["kfcf"]
                var itemsKey = String(this);      //String(Object.keys(newdataArray):["kfcf"]) : kfcf
                //2.根据每个索引找到其对应的Value（value是一个数组，数组里是多个对象）
                var itemsMxArr = newdataArray[String(this)];    //itemsMxArr 取出key为kfcf的所有明细
                // 3.1.1找到key是否为康复处方
                if (itemsKey == "kfcf") {
                    $newtableKfmx.html('');   //先清空html
                    var typeClassificationArr = new Array();
                    for (var i = 0; i < itemsMxArr.length; i++) {
                        var cfh = itemsMxArr[i].cfh;
                        //3.3 判断分类数组是否存在该处方号
                        var existPres = $.jsonWhere(typeClassificationArr, function (v) {
                            return v && v.cfh == cfh;
                        });
                        //3.3.1 若存在，则push该处方号下面的处方明细
                        if (existPres && existPres.length && existPres.length == 1) {
                            continue;
                        }
                        else {
                            //3.3.2 若不存在，则push
                            typeClassificationArr.push({ cfId: itemsMxArr[i].cfId
                                ,cfh: itemsMxArr[i].cfh
                                ,klrq: itemsMxArr[i].klrq
                                ,sfbz: itemsMxArr[i].sfbz
                                ,sendtohisResult: itemsMxArr[i].sendtohisResult
                                ,cfzhdysj: itemsMxArr[i].cfzhdysj
                                , zldzhdysj: itemsMxArr[i].zldzhdysj
                                , tbz: itemsMxArr[i].tbz
                            });
                        }
                    }
                    //遍历处方，呈现之
                    for (var i = 0; i < typeClassificationArr.length; i++) {
                        var lasttdContent = '';
                        lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconPreviewSingleCf" title="处方明细" >Rp</a>';
                        if(typeFlag != "historynodeContent" && !(window.currPatientInfo && window.currPatientInfo.jzzt == '@((int)EnumJzzt.Treated)')){
                            if(typeClassificationArr[i].sfbz == false){
                                lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconEditSingleCf" title="修改处方"><i class="fa fa-pencil-square-o"></i></a>';
                            }
                        }
                        if(!!typeClassificationArr[i].cfId){
                            if(typeFlag != "historynodeContent" && !(window.currPatientInfo && window.currPatientInfo.jzzt == '@((int)EnumJzzt.Treated)')){
                                if (typeClassificationArr[i].sfbz == false) {
                                    if (!(typeClassificationArr[i].sendtohisResult == 1)) {
                                        lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconSendSingleCf" title="发送处方" ><i class="fa fa-paper-plane-o"></i></a>';
                                    }
                                    lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconCancelSingleCf" title="作废处方" ><i class="fa fa-trash-o"></i></a>';
                                } else if (typeClassificationArr[i].sfbz && typeClassificationArr[i].tbz) {
                                    lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconCancelSingleCf" title="作废处方" ><i class="fa fa-trash-o"></i></a>';
                                }
                            }
                            if('@(isPrintRehabPres)' == 'True'){
                                lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconPrintSingleCf" title="打印处方" ><i class="fa fa-print"></i></a>';
                            }
                            if('@(isPrintRehabTreatment)' == 'True'){
                                lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconPrintSingleKfzld" title="打印治疗单" ><i class="fa fa-file-text-o"></i></a>';
                            }
                        }
                        var thisHtml = '<tr style="line-height:30px;" data-cfId="' + typeClassificationArr[i].cfId + '" data-cflx="kfcf" data-cfh="' + typeClassificationArr[i].cfh + '">';
                        thisHtml += '<td>' + typeClassificationArr[i].cfh + '</td>';
                        if(typeFlag != "historynodeContent"){
                            thisHtml += '<td>' + $.getDate({date: typeClassificationArr[i].klrq, ute:true}) + '</td>';
                            thisHtml += '<td>' + (typeClassificationArr[i].sendtohisResult == '1' ? '已同步' : '未同步') + '</td>';
                            thisHtml += '<td>' + (typeClassificationArr[i].sfbz == false ? '未收费' : (typeClassificationArr[i].tbz ? '已退费' : '已收费')) + '</td>';
                            if('@(isPrintRehabPres)' == 'True'){
                                thisHtml += '<td>' + $.getTime({date:typeClassificationArr[i].cfzhdysj,ute:true}) + '</td>';
                            }
                            if('@(isPrintRehabTreatment)' == 'True'){
                                thisHtml += '<td>' + $.getTime({date:typeClassificationArr[i].zldzhdysj,ute:true}) + '</td>';
                            }
                        }
                        thisHtml +=  '<td>' + lasttdContent + '</td></tr>'
                        $newtableKfmx.append(thisHtml);
                    }
                    //对整个类型的处方操作    暂无
                }
                if (itemsKey == "cgxmcf") {
                    $newtableCgxmmx.html('');   //先清空html
                    var typeClassificationArr = new Array();
                    for (var i = 0; i < itemsMxArr.length; i++) {
                        var cfh = itemsMxArr[i].cfh;
                        //3.3 判断分类数组是否存在该处方号
                        var existPres = $.jsonWhere(typeClassificationArr, function (v) {
                            return v && v.cfh == cfh;
                        });
                        //3.3.1 若存在，则push该处方号下面的处方明细
                        if (existPres && existPres.length && existPres.length == 1) {
                            continue;
                        }
                        else {
                            //3.3.2 若不存在，则push
                            typeClassificationArr.push({ cfId: itemsMxArr[i].cfId
                                ,cfh: itemsMxArr[i].cfh
                                ,klrq: itemsMxArr[i].klrq
                                ,sfbz: itemsMxArr[i].sfbz
                                ,sendtohisResult: itemsMxArr[i].sendtohisResult
                                ,cfzhdysj: itemsMxArr[i].cfzhdysj
                                , zldzhdysj: itemsMxArr[i].zldzhdysj
                                , tbz: itemsMxArr[i].tbz
                            });
                        }
                    }
                    //遍历处方，呈现之
                    for (var i = 0; i < typeClassificationArr.length; i++) {
                        var lasttdContent = '';
                        lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconPreviewSingleCf" title="处方明细" >Rp</a>';
                        if(typeFlag != "historynodeContent" && !(window.currPatientInfo && window.currPatientInfo.jzzt == '@((int)EnumJzzt.Treated)')){
                            if(typeClassificationArr[i].sfbz == false){
                                lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconEditSingleCf" title="修改处方"><i class="fa fa-pencil-square-o"></i></a>';
                            }
                        }
                        if(!!typeClassificationArr[i].cfId){
                            if(typeFlag != "historynodeContent" && !(window.currPatientInfo && window.currPatientInfo.jzzt == '@((int)EnumJzzt.Treated)')){
                                if(typeClassificationArr[i].sfbz == false){
                                    if(!(typeClassificationArr[i].sendtohisResult == 1)){
                                        lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconSendSingleCf" title="发送处方" ><i class="fa fa-paper-plane-o"></i></a>';
                                    }
                                    lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconCancelSingleCf" title="作废处方" ><i class="fa fa-trash-o"></i></a>';
                                } else if (typeClassificationArr[i].sfbz && typeClassificationArr[i].tbz) {
                                    lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconCancelSingleCf" title="作废处方" ><i class="fa fa-trash-o"></i></a>';
                                }
                            }
                            lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconPrintSingleCf" title="打印处方" ><i class="fa fa-print"></i></a>';
                        }
                        var thisHtml = '<tr style="line-height:30px;" data-cfId="' + typeClassificationArr[i].cfId + '" data-cflx="cgxmcf" data-cfh="' + typeClassificationArr[i].cfh + '">';
                        thisHtml += '<td>' + typeClassificationArr[i].cfh + '</td>';
                        if(typeFlag != "historynodeContent"){
                            thisHtml += '<td>' + $.getDate({date: typeClassificationArr[i].klrq, ute:true}) + '</td>';
                            thisHtml += '<td>' + (typeClassificationArr[i].sendtohisResult == '1' ? '已同步' : '未同步') + '</td>';
                            thisHtml += '<td>' + (typeClassificationArr[i].sfbz == false ? '未收费' : (typeClassificationArr[i].tbz ? '已退费' : '已收费')) + '</td>';
                            thisHtml += '<td>' + $.getTime({date:typeClassificationArr[i].cfzhdysj,ute:true}) + '</td>';
                        }
                        thisHtml +=  '<td>' + lasttdContent + '</td></tr>'
                        $newtableCgxmmx.append(thisHtml);
                    }
                    //对整个类型的处方操作    暂无
                }
                // 3.1.2找到key是否为西药处方
                if (itemsKey == "xycf") {
                    $newtableXymx.html('');   //先清空html
                    var typeClassificationArr = new Array();
                    for (var i = 0; i < itemsMxArr.length; i++) {
                        var Iscontainwh = false;
                        var Iscontainzs = false;
                        var cfh = itemsMxArr[i].cfh;
                        if (itemsMxArr[i].yfCode) {
                            if ('@ViewBag.ControlwhyfCode' != "" && '@ViewBag.ControlwhyfCode'.indexOf(","+itemsMxArr[i].yfCode+",") > -1) {
                                Iscontainwh = true;
                            }
                            if ('@ViewBag.ControlzsyfCode' != "" && '@ViewBag.ControlzsyfCode'.indexOf(","+itemsMxArr[i].yfCode+",") > -1) {
                                Iscontainzs = true;
                            }
                        }

                        //3.3 判断分类数组是否存在该处方号
                        var existPres = $.jsonWhere(typeClassificationArr, function (v) {
                            if (v && v.cfh == cfh && !v.Iscontainwh && Iscontainwh) {
                                v.Iscontainwh = Iscontainwh;
                            }
                            if (v && v.cfh == cfh && !v.Iscontainzs && Iscontainzs) {
                                v.Iscontainzs = Iscontainzs;
                            }
                            return v && v.cfh == cfh;
                        });
                        //3.3.1 若存在，则push该处方号下面的处方明细
                        if (existPres && existPres.length && existPres.length == 1) {
                            continue;
                        }
                        else {
                            //3.3.2 若不存在，则push
                            typeClassificationArr.push({ cfId: itemsMxArr[i].cfId
                                  ,cfh: itemsMxArr[i].cfh
                                ,klrq: itemsMxArr[i].klrq
                                ,sfbz: itemsMxArr[i].sfbz
                                ,sendtohisResult: itemsMxArr[i].sendtohisResult
                                , cfzhdysj: itemsMxArr[i].cfzhdysj
                                , yfCode: itemsMxArr[i].yfCode
                                , Iscontainwh: Iscontainwh
                                , Iscontainzs: Iscontainzs
                                , tbz: itemsMxArr[i].tbz
                            });
                        }
                    }
                    //遍历处方，呈现之
                    for (var i = 0; i < typeClassificationArr.length; i++) {
                        var lasttdContent = '';
                        lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconPreviewSingleCf" title="处方明细" >Rp</a>';
                        if(typeFlag != "historynodeContent" && !(window.currPatientInfo && window.currPatientInfo.jzzt == '@((int)EnumJzzt.Treated)')){
                            if(typeClassificationArr[i].sfbz == false){
                                lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconEditSingleCf" title="修改处方"><i class="fa fa-pencil-square-o"></i></a>';
                            }
                        }
                        if (!!typeClassificationArr[i].cfId) {
                            if(typeFlag != "historynodeContent" && !(window.currPatientInfo && window.currPatientInfo.jzzt == '@((int)EnumJzzt.Treated)')){
                                if(typeClassificationArr[i].sfbz == false){
                                    if(!(typeClassificationArr[i].sendtohisResult == 1)){
                                        lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconSendSingleCf" title="发送处方" ><i class="fa fa-paper-plane-o"></i></a>';
                                    }
                                    lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconCancelSingleCf" title="作废处方" ><i class="fa fa-trash-o"></i></a>';
                                } else if (typeClassificationArr[i].sfbz && typeClassificationArr[i].tbz) {
                                    lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconCancelSingleCf" title="作废处方" ><i class="fa fa-trash-o"></i></a>';
                                }
                            }
                            lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconPrintSingleCf" title="打印处方" ><i class="fa fa-print"></i></a>';
                            //if (typeClassificationArr[i].yfCode != "" && typeClassificationArr[i].yfCode != undefined) {
                            if (typeClassificationArr[i].Iscontainzs) {
                                    lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconPrintSingleCf" title="打印注射单" ><i class="fa fa-print"></i></a>';
                                }

                            if (typeClassificationArr[i].Iscontainwh) {
                                    lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconPrintSingleCf" title="打印雾化单" ><i class="fa fa-print"></i></a>';
                                }
                            //}
                        }
                        var thisHtml = '<tr style="line-height:30px;" data-cfId="' + typeClassificationArr[i].cfId + '" data-cflx="xycf" data-cfh="' + typeClassificationArr[i].cfh + '">';
                        thisHtml += '<td>' + typeClassificationArr[i].cfh + '</td>';
                        if(typeFlag != "historynodeContent"){
                            thisHtml += '<td>' + $.getDate({date: typeClassificationArr[i].klrq, ute:true}) + '</td>';
                            thisHtml += '<td>' + (typeClassificationArr[i].sendtohisResult == '1' ? '已同步' : '未同步') + '</td>';
                            thisHtml += '<td>' + (typeClassificationArr[i].sfbz == false ? '未收费' : (typeClassificationArr[i].tbz ? '已退费':'已收费')) + '</td>';
                            thisHtml += '<td>' + $.getTime({date:typeClassificationArr[i].cfzhdysj,ute:true}) + '</td>';
                        }
                        thisHtml +=  '<td>' + lasttdContent + '</td></tr>'
                        $newtableXymx.append(thisHtml);
                    }
                    //对整个类型的处方操作    暂无
                }
                // 3.1.3找到key是否为中药处方
                if (itemsKey == "zycf") {
                    $newtableZymx.html('');   //先清空html
                    var typeClassificationArr = new Array();
                    for (var i = 0; i < itemsMxArr.length; i++) {

                        var Iscontainwh = false;
                        var Iscontainzs = false;
                        var cfh = itemsMxArr[i].cfh;

                        if (!itemsMxArr[i].yfCode) {
                            if ('@ViewBag.ControlwhyfCode' != "" && '@ViewBag.ControlwhyfCode'.indexOf(","+itemsMxArr[i].yfCode+",") > -1) {
                                Iscontainwh = true;
                            }
                            if ('@ViewBag.ControlzsyfCode' != "" && '@ViewBag.ControlzsyfCode'.indexOf(","+itemsMxArr[i].yfCode+",") > -1) {
                                Iscontainzs = true;
                            }
                        }
                        //3.3 判断分类数组是否存在该处方号
                        var existPres = $.jsonWhere(typeClassificationArr, function (v) {
                            if (v && v.cfh == cfh && !v.Iscontainwh && Iscontainwh) {
                                v.Iscontainwh = Iscontainwh;
                            }
                            if (v && v.cfh == cfh && !v.Iscontainzs && Iscontainzs) {
                                v.Iscontainzs = Iscontainzs;
                            }
                            return v && v.cfh == cfh;
                        });
                        //3.3.1 若存在，则push该处方号下面的处方明细
                        if (existPres && existPres.length && existPres.length == 1) {
                            continue;
                        }
                        else {
                            //3.3.2 若不存在，则push
                            typeClassificationArr.push({ cfId: itemsMxArr[i].cfId
                                   ,cfh: itemsMxArr[i].cfh
                                ,klrq: itemsMxArr[i].klrq
                                ,sfbz: itemsMxArr[i].sfbz
                                ,sendtohisResult: itemsMxArr[i].sendtohisResult
                                , cfzhdysj: itemsMxArr[i].cfzhdysj
                                , yfCode: itemsMxArr[i].yfCode
                                , Iscontainwh: Iscontainwh
                                , Iscontainzs: Iscontainzs
                                , tbz: itemsMxArr[i].tbz
                            });
                        }
                    }
                    //遍历处方，呈现之
                    for (var i = 0; i < typeClassificationArr.length; i++) {
                        var lasttdContent = '';
                        lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconPreviewSingleCf" title="处方明细" >Rp</a>';
                        if(typeFlag != "historynodeContent" && !(window.currPatientInfo && window.currPatientInfo.jzzt == '@((int)EnumJzzt.Treated)')){
                            if(typeClassificationArr[i].sfbz == false){
                                lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconEditSingleCf" title="修改处方"><i class="fa fa-pencil-square-o"></i></a>';
                            } else if (typeClassificationArr[i].sfbz && typeClassificationArr[i].tbz) {
                                lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconCancelSingleCf" title="作废处方" ><i class="fa fa-trash-o"></i></a>';
                            }
                        }
                        if(!!typeClassificationArr[i].cfId){
                            if(typeFlag != "historynodeContent" && !(window.currPatientInfo && window.currPatientInfo.jzzt == '@((int)EnumJzzt.Treated)')){
                                if(typeClassificationArr[i].sfbz == false){
                                    if(!(typeClassificationArr[i].sendtohisResult == 1)){
                                        lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconSendSingleCf" title="发送处方" ><i class="fa fa-paper-plane-o"></i></a>';
                                    }
                                    lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconCancelSingleCf" title="作废处方" ><i class="fa fa-trash-o"></i></a>';
                                }
                            }
                            lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconPrintSingleCf" title="打印处方" ><i class="fa fa-print"></i></a>';
                            if (typeClassificationArr[i].Iscontainzs) {
                                lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconPrintSingleCf" title="打印注射单" ><i class="fa fa-print"></i></a>';
                            }
                            if (typeClassificationArr[i].Iscontainwh) {
                                lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconPrintSingleCf" title="打印雾化单" ><i class="fa fa-print"></i></a>';
                            }
                        }
                        var thisHtml = '<tr style="line-height:30px;" data-cfId="' + typeClassificationArr[i].cfId + '" data-cflx="zycf" data-cfh="' + typeClassificationArr[i].cfh + '">';
                        thisHtml += '<td>' + typeClassificationArr[i].cfh + '</td>';
                        if(typeFlag != "historynodeContent"){
                            thisHtml += '<td>' + $.getDate({date: typeClassificationArr[i].klrq, ute:true}) + '</td>';
                            thisHtml += '<td>' + (typeClassificationArr[i].sendtohisResult == '1' ? '已同步' : '未同步') + '</td>';
                            thisHtml += '<td>' + (typeClassificationArr[i].sfbz == false ? '未收费' : (typeClassificationArr[i].tbz ? '已退费' : '已收费')) + '</td>';
                            thisHtml += '<td>' + $.getTime({date:typeClassificationArr[i].cfzhdysj,ute:true}) + '</td>';
                        }
                        thisHtml +=  '<td>' + lasttdContent + '</td></tr>'
                        $newtableZymx.append(thisHtml);
                    }
                    //对整个类型的处方操作    暂无
                }
                // 3.1.4找到key是否为检验申请单
                if (itemsKey == "jycf") {
                    $newtableJymx.html('');   //先清空html
                    var typeClassificationArr = new Array();
                    for (var i = 0; i < itemsMxArr.length; i++) {
                        var cfh = itemsMxArr[i].cfh;
                        //3.3 判断分类数组是否存在该处方号
                        var existPres = $.jsonWhere(typeClassificationArr, function (v) {
                            return v && v.cfh == cfh;
                        });
                        //3.3.1 若存在，则push该处方号下面的处方明细
                        if (existPres && existPres.length && existPres.length == 1) {
                            continue;
                        }
                        else {
                            //3.3.2 若不存在，则push
                            typeClassificationArr.push({ cfId: itemsMxArr[i].cfId
                                         ,cfh: itemsMxArr[i].cfh
                                ,klrq: itemsMxArr[i].klrq
                                ,sfbz: itemsMxArr[i].sfbz
                                , sendtohisResult: itemsMxArr[i].sendtohisResult
                                , tbz: itemsMxArr[i].tbz
                            });
                        }
                    }
                    //遍历处方，呈现之
                    for (var i = 0; i < typeClassificationArr.length; i++) {
                        var lasttdContent = '';
                        lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconPreviewSingleCf" title="申请单明细" >Req</a>';
                        if(!!typeClassificationArr[i].cfId){
                            if(typeFlag != "historynodeContent" && !(window.currPatientInfo && window.currPatientInfo.jzzt == '@((int)EnumJzzt.Treated)')){
                                if(typeClassificationArr[i].sfbz == false){
                                    if(!(typeClassificationArr[i].sendtohisResult == 1)){
                                        lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconSendSingleCf" title="发送申请单" ><i class="fa fa-paper-plane-o"></i></a>';
                                    }
                                    lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconCancelSingleCf" title="作废申请单" ><i class="fa fa-trash-o"></i></a>';
                                } else if (typeClassificationArr[i].sfbz && typeClassificationArr[i].tbz) {
                                    lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconCancelSingleCf" title="作废处方" ><i class="fa fa-trash-o"></i></a>';
                                }
                            }
                            //lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconPrintSingleCf" title="打印检验处方" ><i class="fa fa-print"></i></a>';

                            lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconPrintSingleCf" title="打印检验单" ><i class="fa fa-print"></i></a>';

                        }
                        var thisHtml = '<tr style="line-height:30px;" data-cfId="' + typeClassificationArr[i].cfId + '" data-cflx="jycf" data-cfh="' + typeClassificationArr[i].cfh + '">';
                        thisHtml += '<td>' + typeClassificationArr[i].cfh + '</td>';
                        if(typeFlag != "historynodeContent"){
                            thisHtml += '<td>' + $.getDate({date: typeClassificationArr[i].klrq, ute:true}) + '</td>';
                            thisHtml += '<td>' + (typeClassificationArr[i].sendtohisResult == '1' ? '已同步' : '未同步') + '</td>';
                            thisHtml += '<td>' + (typeClassificationArr[i].sfbz == false ? '未收费' : (typeClassificationArr[i].tbz ? '已退费' : '已收费')) + '</td>';
                        }
                        thisHtml +=  '<td>' + lasttdContent + '</td></tr>'
                        $newtableJymx.append(thisHtml);
                    }
                    //对整个类型的处方操作    暂无
                }
                // 3.1.5找到key是否为检查申请单
                if (itemsKey == "jccf") {
                    $newtableJcmx.html('');   //先清空html
                    var typeClassificationArr = new Array();
                    for (var i = 0; i < itemsMxArr.length; i++) {
                        var cfh = itemsMxArr[i].cfh;
                        //3.3 判断分类数组是否存在该处方号
                        var existPres = $.jsonWhere(typeClassificationArr, function (v) {
                            return v && v.cfh == cfh;
                        });
                        //3.3.1 若存在，则push该处方号下面的处方明细
                        if (existPres && existPres.length && existPres.length == 1) {
                            continue;
                        }
                        else {
                            //3.3.2 若不存在，则push
                            typeClassificationArr.push({ cfId: itemsMxArr[i].cfId
                                     ,cfh: itemsMxArr[i].cfh
                                ,klrq: itemsMxArr[i].klrq
                                ,sfbz: itemsMxArr[i].sfbz
                                , sendtohisResult: itemsMxArr[i].sendtohisResult
                                , tbz: itemsMxArr[i].tbz
                            });
                        }
                    }
                    //遍历处方，呈现之
                    for (var i = 0; i < typeClassificationArr.length; i++) {
                        var lasttdContent = '';
                        lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconPreviewSingleCf" title="申请单明细" >Req</a>';
                        if(!!typeClassificationArr[i].cfId){
                            if(typeFlag != "historynodeContent" && !(window.currPatientInfo && window.currPatientInfo.jzzt == '@((int)EnumJzzt.Treated)')){
                                if(typeClassificationArr[i].sfbz == false){
                                    if(!(typeClassificationArr[i].sendtohisResult == 1)){
                                        lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconSendSingleCf" title="发送申请单" ><i class="fa fa-paper-plane-o"></i></a>';
                                    }
                                    lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconCancelSingleCf" title="作废申请单" ><i class="fa fa-trash-o"></i></a>';
                                } else if (typeClassificationArr[i].sfbz && typeClassificationArr[i].tbz) {
                                    lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconCancelSingleCf" title="作废处方" ><i class="fa fa-trash-o"></i></a>';
                                }
                            }
                            //lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconPrintSingleCf" title="打印检查处方" ><i class="fa fa-print"></i></a>';
                            lasttdContent += '&nbsp;&nbsp;<a class="btn btn-default btn-md iconPrintSingleCf" title="打印检查单" ><i class="fa fa-print"></i></a>';

                        }
                        var thisHtml = '<tr style="line-height:30px;" data-cfId="' + typeClassificationArr[i].cfId + '" data-cflx="jccf" data-cfh="' + typeClassificationArr[i].cfh + '">';
                        thisHtml += '<td>' + typeClassificationArr[i].cfh + '</td>';
                        if(typeFlag != "historynodeContent"){
                            thisHtml += '<td>' + $.getDate({date: typeClassificationArr[i].klrq, ute:true}) + '</td>';
                            thisHtml += '<td>' + (typeClassificationArr[i].sendtohisResult == '1' ? '已同步' : '未同步') + '</td>';
                            thisHtml += '<td>' + ((typeClassificationArr[i].sfbz == false) ? '未收费' : (typeClassificationArr[i].tbz ? '已退费' : '已收费')) + '</td>';
                        }
                        thisHtml +=  '<td>' + lasttdContent + '</td></tr>'
                        $newtableJcmx.append(thisHtml);
                    }
                    //对整个类型的处方操作    暂无
                }
            })
        }
    }


    ////复制
    //$('#btncopy').click(function () {
    //    $.modalConfirm("将替换病历详情的内容，是否继续？", function (flag) {
    //        if (flag) {
    //            var treeSeleData = $("#detailTreeNode").getCheckedNodeObjArray();
    //            $.modalClose();
    //        } else {
    //            return false;
    //        }
    //    });
    //});

    function submitForm() {
        var treeSeleData = $("#detailTreeNode").getCheckedNodeObjArray();
        if (!treeSeleData || treeSeleData.length == 0) {
            $.modalAlert("请选择处方进行复制", 'warning');
            return;
        }
        return treeSeleData;
    }

</script>